From: Colin Walters Date: Fri, 21 Mar 2025 12:11:50 +0000 (-0400) Subject: tests/auto-prune: Don't go negative X-Git-Tag: archive/raspbian/2025.7-2+rpi1^2^2~6^2~5^2~1 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/%22stanciumarius94%40gmail.com//%22mailto:i18n-csb%40linuxcsb.org/%22/%22http:/www.example.com/%22stanciumarius94%40gmail.com/%22mailto:i18n-csb%40linuxcsb.org/%22?a=commitdiff_plain;h=75f2f7d50d07c0a98f429e6974685a87adea9584;p=ostree.git tests/auto-prune: Don't go negative - First I kept wondering what the magic of 10000 was here before looking above and noticing it matched the number of dtb files. Make a shared variable so the connection is more obvious - Next, I *believe* the intention of this test was to test the edge case of bytes vs blocks, but we ended up subtracting blocks and I think recent FCOS images happened to get small enough that we started going negative here. Fix this to convert the bytes into blocks. --- diff --git a/tests/kolainst/destructive/auto-prune.sh b/tests/kolainst/destructive/auto-prune.sh index 03d60e41..38e88af0 100755 --- a/tests/kolainst/destructive/auto-prune.sh +++ b/tests/kolainst/destructive/auto-prune.sh @@ -33,6 +33,8 @@ assert_not_journal_grep() { fi } +block_size=$(stat --file-system /boot -c '%s') + # make two fake ostree commits with modified kernels of about the same size cd /root mkdir -p rootfs/usr/lib/modules/`uname -r` @@ -53,9 +55,8 @@ assert_bootfs_has_n_bootcsum_dirs() { } consume_bootfs_space() { - local free_blocks block_size + local free_blocks free_blocks=${1:-$(stat --file-system /boot -c '%a')} - block_size=$(stat --file-system /boot -c '%s') # leave 1 block free unshare -m bash -c \ "mount -o rw,remount /boot && \ @@ -173,11 +174,13 @@ assert_journal_grep "$cursor" "updating bootloader in two steps" unconsume_bootfs_space mkdir -p rootfs/usr/lib/modules/`uname -r`/dtb -(set +x; for i in {1..10000}; do echo -n x > rootfs/usr/lib/modules/`uname -r`/dtb/$i; done) +dtbcount=10000 +(set +x; for i in {1..${dtbcount}}; do echo -n x > rootfs/usr/lib/modules/`uname -r`/dtb/$i; done) ostree commit --base modkernel1 -P --tree=dir=rootfs -b modkernel3 # a naive estimator would think all those files just take 10000 bytes -consume_bootfs_space "$((free_blocks_kernel_and_initrd - 10000))" +dtb_naive_space=$((${dtbcount} / ${block_size})) +consume_bootfs_space "$((free_blocks_kernel_and_initrd - ${dtb_naive_space}))" rpm-ostree rebase :modkernel3 cursor=$(journal_cursor)